#coding:utf-8
import sys, os, json
from pic_comparator import PicScanner, Md5PicComparator

def main(path, writePath):
    scanner = PicScanner(path)
    comparator = Md5PicComparator()
    result = scanner.run(comparator)

    # print 'dulicate result:\n' + json.dumps(result, ensure_ascii=False)
    fout = open(writePath, "w")
    fout.write(json.dumps(result, ensure_ascii=False))
    fout.close()
    
    return 0


if __name__ == "__main__":
    argv = sys.argv
    path = argv[1]
    writePath = argv[2]

    print 'argv = %s' % argv
    if path is None:
        print 'Need Search Path!'
        sys.exit(-1);
    else:
        sys.exit(main(path, writePath))
